class Solution {
public:
    ListNode* deleteDuplicates(ListNode* head) {
if (!head){
            return head;
        }
        if (head->next && head->val == head->next->val){
            while (head->next && head->val == head->next->val){
                head = head->next;
            }
            return deleteDuplicates(head->next);
        }else {
            head->next = deleteDuplicates(head->next);
        }
        return head;

    }
};